import publicForm from "@/components/public/el-form.vue"; //弹框form
import TableData from '@/components/public/el-tables'; //列表
import formJs from "./regexDetail.js"; //新增弹框配置项
import {
    getSteelProtectionTestTaskData, //详情

} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "tableTitle"
    ],
    // 
    data() {
        return {
            visible: "",
            tableDta:null,
            btnShow: true,
            selecttTotalIdIndex: null,
            loading: false,
            totalData: null,
            personList: null,
            contentTableResultData: null,
            title: null,
            isLock: false,
            dialogHeight: null,
            activeIndex: "1",
            formObj: formJs.formObj,
            currntData: null,
            currentDetail: null,
            reportTableObj: formJs.reportTableObj, // 报告上
            reportTableObj1:formJs.reportTableObj1,
               echartsData: null,
            formData: null,
            contentTableLeft: [],
            contentTableRight: [], //计算结果集合fParam 
            // 审批流程
            table_config: formJs.table_config, //列表
            queryCriteriaData: {}, //分页
            tableData: [],
            // 审批流程

        };
    },
    components: {
        publicForm,
        TableData,
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },


        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    this.getDetail({
                        fId: this.currentDetail.fId
                    })
                    this.getPerson(this.currentDetail.fCompanyid)

                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：
    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
        this.getHeight();
    },
    methods: {
        tableRowClassName({
            row,
            column,
            rowIndex,
            columnIndex
        }) {
            //把每一行的索引放进row,和index
            row.index = rowIndex;
            column.index = columnIndex;
        },

        inputValue() {},
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 1 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        // 页签切换
        changeType(e, index) {
            for (let i in this.typeData) {
                if (parseFloat(i) === index) {
                    this.typeData[i].show = true;
                } else {
                    this.typeData[i].show = false;
                }
            }
            // this.typeDataNum = index;
        },
        // 页签切换
        resetObject(obj) {
            return Object.assign({}, obj); // 创建一个新的空对象，然后将原始对象的属性赋值给这个新对象
        },

        // 调用 map() 函数，传入上面定义的 resetObject 函数作为参数
        // 详情
        getDetail(obj) {
            this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
            this.loading = true;
            // this.reportResultData.map((item) => this.resetObject(item));
            getSteelProtectionTestTaskData(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading = false;

                    var data = res.data.testTask;
                    this.tableDta=data.checkPointList;
                    console.log(data, 999);
                    this.totalData = res.data;
                    this.formData = res.data.testTask;
                    this.tableData = res.data.taskList;
                    this.reportTableObj.map(item => {
                        var name = item.value
                        item['key'] = data[name]
                    })
                    this.reportTableObj1.map(item => {
                        var name = item.value
                        item['key'] = data[name]
                    })
                    console.log('this.reportTableObj1',this.reportTableObj1);

                } else {
                    this.loading = false;
                    this.$message.error(res.msg);
                }
            });
        },
   

    },
};